// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use global_hotkey::GlobalHotKeyEvent;

fn main() {
    // 监听全局事件，必须在主线程中调用
    std::thread::spawn(|| {
        loop {
            let event = GlobalHotKeyEvent::receiver().recv();
            if event.is_err() {
                log::error!("接收全局快捷键事件失败：{}", event.unwrap_err());

                continue;
            }

            let event = event.unwrap();
            log::debug!("全局快捷键事件: {:?}", event);

            magic_box::runner::shortcut::handle(event);
        }
    });

    magic_box::runner::runner::run().expect("启动失败")
}